package com.yycx.module.bus.provider.handler.custombond;

import com.yycx.common.base.entity.EntityMap;
import com.yycx.common.base.utils.FlymeUtils;
import com.yycx.common.constants.CommonConstants;
import com.yycx.common.mybatis.interceptor.SaveInterceptor;
import com.yycx.common.mybatis.query.CriteriaSave;
import com.yycx.common.security.OpenHelper;
import com.yycx.common.utils.ApiAssert;
import com.yycx.common.utils.OrderNoUtil;
import com.yycx.module.bus.client.entity.BusPayment;
import com.yycx.module.bus.client.enums.AmountTypeEnum;
import com.yycx.module.bus.provider.service.BusDeptService;
import com.yycx.module.bus.provider.service.BusOrderDetailsService;
import com.yycx.module.bus.provider.service.BusOrderService;
import com.yycx.module.bus.provider.service.BusPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 市场保证金保存扩展器
 *
 * @author zyf
 */
@Component("customBondPaymentSaveHandler")
public class CustomBondPaymentSaveHandler implements SaveInterceptor<BusPayment> {

    @Autowired
    private BusDeptService deptService;

    @Autowired
    private BusPaymentService paymentService;

    @Autowired
    private BusOrderService orderService;

    @Autowired
    private BusOrderDetailsService orderDetailsService;
    @Resource
    private OrderNoUtil orderNoUtil;

    @Override
    public void prepare(CriteriaSave cs, EntityMap entityMap, BusPayment payment) {
        String orderNo = orderNoUtil.getIncrementNum();
        payment.setPaymentNo("BJ" + orderNo);
        payment.setTitle("市场保证金");
        payment.setAmountType(AmountTypeEnum.CustomBond.getCode());
        payment.setOrganizationId(OpenHelper.getOrganizationId());
        payment.setCompanyId(OpenHelper.getCompanyId());
        payment.setUserId(OpenHelper.getUserId());
        payment.setNickName(OpenHelper.getNickName());
        payment.setPaymentState(CommonConstants.INT_0);
    }


}
